/*************************************************************************
	> File Name: P1781.cpp
	> Author: yufangze
	> Mail: 2224590123@qq.com
	> Created Time: 2025-04-16 15:14:17
 ************************************************************************/

#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
    int n, id = 0;
    string ans = "";
    cin >> n;
    for (int i = 1; i <= n; i++) {
        string str;
        cin >> str;
        if (str.size() != ans.size()) {
            if (str.size() > ans.size()) {
                ans = str;
                id = i;
            }
        } else {
            if (str > ans) {
                ans = str;
                id = i;
            }
        }
    }
    cout << id << endl << ans << endl;
    return 0;
}
